Batsman Jason Roy, who starred in England's World Cup triumph, is another name missing from the 15-strong Test squad after a difficult Ashes series, which ended 2-2 last week.
Surrey batsman Ollie Pope, who played two Tests against India in 2018, is back in the squad while Jos Buttler will be the wicketkeeper in New Zealand due to Bairstow's absence.
Bairstow, 29, scored just 214 runs in the five Ashes Tests during the English summer at an average of 23.77.
Anderson, England's top Test wicket-taker, has been out of action since the first Test against Australia and is targeting the South Africa tour, starting in December.
The first Test, at Mount Maunganui, starts on November 21. The series is not included in the new World Test Championship. National selector Ed Smith confirmed Bairstow, who will travel with the 15-man T20 squad, had been dropped rather than rested.
"This feels like an opportunity for Jonny to reset," he said on Sky Sports.
World Cup-winning captain Eoin Morgan will captain the Twenty20 team, with the five-match series starting on November 1.
Somerset's Tom Banton and Mahmood have earned their first England call-ups after impressive white-ball summers, along with Worcestershire seamer Pat Brown and Lancashire spinner Matthew Parkinson.
Test squad: Joe Root (capt), Jofra Archer, Stuart Broad, Rory Burns, Jos Buttler, Zak Crawley, Sam Curran, Joe Denly, Jack Leach, Saqib Mahmood, Matthew Parkinson, Ollie Pope, Dominic Sibley, Ben Stokes, Chris Woakes
Twenty20 squad: Eoin Morgan (capt), Jonny Bairstow, Tom Banton, Sam Billings, Pat Brown, Sam Curran, Tom Curran, Joe Denly, Lewis Gregory, Chris Jordan, Saqib Mahmood, Dawid Malan, Matt Parkinson, Adil Rashid, James Vince.